bitkeeper revision 1.971.1.1 (40d163adsjmFburVM5p7loFTWzaluA)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Thu, 17 Jun 2004 09:26:05 +0000 (09:26 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Thu, 17 Jun 2004 09:26:05 +0000 (09:26 +0000)
More cleanups.

xen/arch/x86/extable.c
xen/arch/x86/io_apic.c
xen/arch/x86/irq.c
xen/arch/x86/nmi.c

index af37b8601388c1dc3888fb6120a73eb477cc301f..6dc4a2e634e74e796b1e77b379f573b808d9ef8f 100644 (file)
@@ -1,9 +1,5 @@
-/*
- * linux/arch/i386/mm/extable.c
- */
 
 #include <xen/config.h>
-#include <xen/module.h>
 #include <xen/spinlock.h>
 #include <asm/uaccess.h>
 
@@ -15,48 +11,25 @@ search_one_table(const struct exception_table_entry *first,
                 const struct exception_table_entry *last,
                 unsigned long value)
 {
-        while (first <= last) {
-               const struct exception_table_entry *mid;
-               long diff;
+    const struct exception_table_entry *mid;
+    long diff;
 
-               mid = (last - first) / 2 + first;
-               diff = mid->insn - value;
-                if (diff == 0)
-                        return mid->fixup;
-                else if (diff < 0)
-                        first = mid+1;
-                else
-                        last = mid-1;
-        }
-        return 0;
+    while ( first <= last )
+    {
+        mid = (last - first) / 2 + first;
+        diff = mid->insn - value;
+        if (diff == 0)
+            return mid->fixup;
+        else if (diff < 0)
+            first = mid+1;
+        else
+            last = mid-1;
+    }
+    return 0;
 }
 
-extern spinlock_t modlist_lock;
-
 unsigned long
 search_exception_table(unsigned long addr)
 {
-       unsigned long ret = 0;
-       
-#ifndef CONFIG_MODULES
-       /* There is only the kernel to search.  */
-       ret = search_one_table(__start___ex_table, __stop___ex_table-1, addr);
-       return ret;
-#else
-       unsigned long flags;
-       /* The kernel is the last "module" -- no need to treat it special.  */
-       struct module *mp;
-
-       spin_lock_irqsave(&modlist_lock, flags);
-       for (mp = module_list; mp != NULL; mp = mp->next) {
-               if (mp->ex_table_start == NULL || !(mp->flags&(MOD_RUNNING|MOD_INITIALIZING)))
-                       continue;
-               ret = search_one_table(mp->ex_table_start,
-                                      mp->ex_table_end - 1, addr);
-               if (ret)
-                       break;
-       }
-       spin_unlock_irqrestore(&modlist_lock, flags);
-       return ret;
-#endif
+    return search_one_table(__start___ex_table, __stop___ex_table-1, addr);
 }
index 9c94e787e0681cf676bfa9b28614fee765be2621..41371307106adcff2d7b16e4e4adebd1a2020eae 100644 (file)
@@ -1252,7 +1252,7 @@ static int __init timer_irq_works(void)
 {
        unsigned int t1 = jiffies;
 
-       sti();
+       __sti();
        /* Let ten ticks pass... */
        mdelay((10 * 1000) / HZ);
 
index 56da0f73ec27e4923045a6c592bd3d98a57f262f..068085d0db32ae4a412a4449c087eecf7b8fc06e 100644 (file)
@@ -37,7 +37,6 @@
 #include <asm/bitops.h>
 #include <asm/flushtlb.h>
 #include <xen/delay.h>
-#include <xen/timex.h>
 #include <xen/perfc.h>
 #include <asm/smpboot.h>
 
 irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned =
 { [0 ... NR_IRQS-1] = { 0, &no_irq_type, NULL, 0, SPIN_LOCK_UNLOCKED}};
 
-#ifdef CONFIG_SMP
-/* NB. XXX We'll want some way of fiddling with this from DOM0. */
-unsigned long irq_affinity [NR_IRQS] = { [0 ... NR_IRQS-1] = ~0UL };
-#endif
-
 static void __do_IRQ_guest(int irq);
 
 /*
@@ -131,205 +125,6 @@ atomic_t irq_mis_count;
  * Generic, controller-independent functions:
  */
 
-/*
- * Global interrupt locks for SMP. Allow interrupts to come in on any
- * CPU, yet make cli/sti act globally to protect critical regions..
- */
-
-#ifdef CONFIG_SMP
-unsigned char global_irq_holder = 0xff;
-unsigned volatile long global_irq_lock; /* pendantic: long for set_bit --RR */
-        
-#define MAXCOUNT 100000000
-
-/*
- * I had a lockup scenario where a tight loop doing
- * spin_unlock()/spin_lock() on CPU#1 was racing with
- * spin_lock() on CPU#0. CPU#0 should have noticed spin_unlock(), but
- * apparently the spin_unlock() information did not make it
- * through to CPU#0 ... nasty, is this by design, do we have to limit
- * 'memory update oscillation frequency' artificially like here?
- *
- * Such 'high frequency update' races can be avoided by careful design, but
- * some of our major constructs like spinlocks use similar techniques,
- * it would be nice to clarify this issue. Set this define to 0 if you
- * want to check whether your system freezes.  I suspect the delay done
- * by SYNC_OTHER_CORES() is in correlation with 'snooping latency', but
- * i thought that such things are guaranteed by design, since we use
- * the 'LOCK' prefix.
- */
-#define SUSPECTED_CPU_OR_CHIPSET_BUG_WORKAROUND 0
-
-#if SUSPECTED_CPU_OR_CHIPSET_BUG_WORKAROUND
-# define SYNC_OTHER_CORES(x) udelay(x+1)
-#else
-/*
- * We have to allow irqs to arrive between __sti and __cli
- */
-# define SYNC_OTHER_CORES(x) __asm__ __volatile__ ("nop")
-#endif
-
-static inline void wait_on_irq(int cpu)
-{
-    for (;;) {
-
-        /*
-         * Wait until all interrupts are gone. Wait
-         * for bottom half handlers unless we're
-         * already executing in one..
-         */
-        if (!irqs_running())
-            if (local_bh_count(cpu))
-                break;
-
-        /* Duh, we have to loop. Release the lock to avoid deadlocks */
-        clear_bit(0,&global_irq_lock);
-
-        for (;;) {
-            __sti();
-            SYNC_OTHER_CORES(cpu);
-            __cli();
-            if (irqs_running())
-                continue;
-            if (global_irq_lock)
-                continue;
-            if (!local_bh_count(cpu))
-                continue;
-            if (!test_and_set_bit(0,&global_irq_lock))
-                break;
-        }
-    }
-}
-
-/*
- * This is called when we want to synchronize with
- * interrupts. We may for example tell a device to
- * stop sending interrupts: but to make sure there
- * are no interrupts that are executing on another
- * CPU we need to call this function.
- */
-void synchronize_irq(void)
-{
-    if (irqs_running()) {
-        /* Stupid approach */
-        cli();
-        sti();
-    }
-}
-
-static inline void get_irqlock(int cpu)
-{
-    if (test_and_set_bit(0,&global_irq_lock)) {
-        /* do we already hold the lock? */
-        if ((unsigned char) cpu == global_irq_holder)
-            return;
-        /* Uhhuh.. Somebody else got it. Wait.. */
-        do {
-            do {
-                rep_nop();
-            } while (test_bit(0,&global_irq_lock));
-        } while (test_and_set_bit(0,&global_irq_lock));         
-    }
-    /* 
-     * We also to make sure that nobody else is running
-     * in an interrupt context. 
-     */
-    wait_on_irq(cpu);
-
-    /*
-     * Ok, finally..
-     */
-    global_irq_holder = cpu;
-}
-
-#define EFLAGS_IF_SHIFT 9
-
-/*
- * A global "cli()" while in an interrupt context
- * turns into just a local cli(). Interrupts
- * should use spinlocks for the (very unlikely)
- * case that they ever want to protect against
- * each other.
- *
- * If we already have local interrupts disabled,
- * this will not turn a local disable into a
- * global one (problems with spinlocks: this makes
- * save_flags+cli+sti usable inside a spinlock).
- */
-void __global_cli(void)
-{
-    unsigned int flags;
-
-    __save_flags(flags);
-    if (flags & (1 << EFLAGS_IF_SHIFT)) {
-        int cpu = smp_processor_id();
-        __cli();
-        if (!local_irq_count(cpu))
-            get_irqlock(cpu);
-    }
-}
-
-void __global_sti(void)
-{
-    int cpu = smp_processor_id();
-
-    if (!local_irq_count(cpu))
-        release_irqlock(cpu);
-    __sti();
-}
-
-/*
- * SMP flags value to restore to:
- * 0 - global cli
- * 1 - global sti
- * 2 - local cli
- * 3 - local sti
- */
-unsigned long __global_save_flags(void)
-{
-    int retval;
-    int local_enabled;
-    unsigned long flags;
-    int cpu = smp_processor_id();
-
-    __save_flags(flags);
-    local_enabled = (flags >> EFLAGS_IF_SHIFT) & 1;
-    /* default to local */
-    retval = 2 + local_enabled;
-
-    /* check for global flags if we're not in an interrupt */
-    if (!local_irq_count(cpu)) {
-        if (local_enabled)
-            retval = 1;
-        if (global_irq_holder == cpu)
-            retval = 0;
-    }
-    return retval;
-}
-
-void __global_restore_flags(unsigned long flags)
-{
-    switch (flags) {
-    case 0:
-        __global_cli();
-        break;
-    case 1:
-        __global_sti();
-        break;
-    case 2:
-        __cli();
-        break;
-    case 3:
-        __sti();
-        break;
-    default:
-        printk("global_restore_flags: %08lx (%08lx)\n",
-               flags, (&flags)[-1]);
-    }
-}
-
-#endif
-
 /*
  * This should really return information about whether
  * we should do bottom half handling etc. Right now we
@@ -693,204 +488,6 @@ void free_irq(unsigned int irq, void *dev_id)
     }
 }
 
-/*
- * IRQ autodetection code..
- *
- * This depends on the fact that any interrupt that
- * comes in on to an unassigned handler will get stuck
- * with "IRQ_WAITING" cleared and the interrupt
- * disabled.
- */
-
-static spinlock_t probe_sem = SPIN_LOCK_UNLOCKED;
-
-/**
- *      probe_irq_on    - begin an interrupt autodetect
- *
- *      Commence probing for an interrupt. The interrupts are scanned
- *      and a mask of potential interrupt lines is returned.
- *
- */
-unsigned long probe_irq_on(void)
-{
-    unsigned int i;
-    irq_desc_t *desc;
-    unsigned long val;
-    unsigned long s=0, e=0;
-
-    spin_lock(&probe_sem);
-    /* 
-     * something may have generated an irq long ago and we want to
-     * flush such a longstanding irq before considering it as spurious. 
-     */
-    for (i = NR_IRQS-1; i > 0; i--)  {
-        desc = irq_desc + i;
-
-        spin_lock_irq(&desc->lock);
-        if (!irq_desc[i].action) 
-            irq_desc[i].handler->startup(i);
-        spin_unlock_irq(&desc->lock);
-    }
-
-    /* Wait for longstanding interrupts to trigger (20ms delay). */
-    rdtscl(s);
-    do {
-        synchronize_irq();
-        rdtscl(e);
-    } while ( ((e-s)/ticks_per_usec) < 20000 );
-
-    /*
-     * enable any unassigned irqs
-     * (we must startup again here because if a longstanding irq
-     * happened in the previous stage, it may have masked itself)
-     */
-    for (i = NR_IRQS-1; i > 0; i--) {
-        desc = irq_desc + i;
-
-        spin_lock_irq(&desc->lock);
-        if (!desc->action) {
-            desc->status |= IRQ_AUTODETECT | IRQ_WAITING;
-            if (desc->handler->startup(i))
-                desc->status |= IRQ_PENDING;
-        }
-        spin_unlock_irq(&desc->lock);
-    }
-
-    /*
-     * Wait for spurious interrupts to trigger (100ms delay). 
-     */
-    rdtscl(s);
-    do {
-        synchronize_irq();
-        rdtscl(e);
-    } while ( ((e-s)/ticks_per_usec) < 100000 );
-
-    /*
-     * Now filter out any obviously spurious interrupts
-     */
-    val = 0;
-    for (i = 0; i < NR_IRQS; i++) {
-        irq_desc_t *desc = irq_desc + i;
-        unsigned int status;
-
-        spin_lock_irq(&desc->lock);
-        status = desc->status;
-
-        if (status & IRQ_AUTODETECT) {
-            /* It triggered already - consider it spurious. */
-            if (!(status & IRQ_WAITING)) {
-                desc->status = status & ~IRQ_AUTODETECT;
-                desc->handler->shutdown(i);
-            } else
-                if (i < 32)
-                    val |= 1 << i;
-        }
-        spin_unlock_irq(&desc->lock);
-    }
-
-    return val;
-}
-
-/*
- * Return a mask of triggered interrupts (this
- * can handle only legacy ISA interrupts).
- */
-/**
- *      probe_irq_mask - scan a bitmap of interrupt lines
- *      @val:   mask of interrupts to consider
- *
- *      Scan the ISA bus interrupt lines and return a bitmap of
- *      active interrupts. The interrupt probe logic state is then
- *      returned to its previous value.
- *
- *      Note: we need to scan all the irq's even though we will
- *      only return ISA irq numbers - just so that we reset them
- *      all to a known state.
- */
-unsigned int probe_irq_mask(unsigned long val)
-{
-    int i;
-    unsigned int mask;
-
-    mask = 0;
-    for (i = 0; i < NR_IRQS; i++) {
-        irq_desc_t *desc = irq_desc + i;
-        unsigned int status;
-
-        spin_lock_irq(&desc->lock);
-        status = desc->status;
-
-        if (status & IRQ_AUTODETECT) {
-            if (i < 16 && !(status & IRQ_WAITING))
-                mask |= 1 << i;
-
-            desc->status = status & ~IRQ_AUTODETECT;
-            desc->handler->shutdown(i);
-        }
-        spin_unlock_irq(&desc->lock);
-    }
-    spin_unlock(&probe_sem);
-
-    return mask & val;
-}
-
-/*
- * Return the one interrupt that triggered (this can
- * handle any interrupt source).
- */
-
-/**
- *      probe_irq_off   - end an interrupt autodetect
- *      @val: mask of potential interrupts (unused)
- *
- *      Scans the unused interrupt lines and returns the line which
- *      appears to have triggered the interrupt. If no interrupt was
- *      found then zero is returned. If more than one interrupt is
- *      found then minus the first candidate is returned to indicate
- *      their is doubt.
- *
- *      The interrupt probe logic state is returned to its previous
- *      value.
- *
- *      BUGS: When used in a module (which arguably shouldnt happen)
- *      nothing prevents two IRQ probe callers from overlapping. The
- *      results of this are non-optimal.
- */
-int probe_irq_off(unsigned long val)
-{
-    int i, irq_found, nr_irqs;
-
-    nr_irqs = 0;
-    irq_found = 0;
-    for (i = 0; i < NR_IRQS; i++) {
-        irq_desc_t *desc = irq_desc + i;
-        unsigned int status;
-
-        spin_lock_irq(&desc->lock);
-        status = desc->status;
-
-        if (status & IRQ_AUTODETECT) {
-            if (!(status & IRQ_WAITING)) {
-                if (!nr_irqs)
-                    irq_found = i;
-                nr_irqs++;
-            }
-            desc->status = status & ~IRQ_AUTODETECT;
-            desc->handler->shutdown(i);
-        }
-        spin_unlock_irq(&desc->lock);
-    }
-    spin_unlock(&probe_sem);
-
-    if (nr_irqs > 1)
-        irq_found = -irq_found;
-    return irq_found;
-}
-
-/* this was setup_x86_irq but it seems pretty generic */
 int setup_irq(unsigned int irq, struct irqaction * new)
 {
     int shared = 0;
index 8422367492e59d8b4bebda624b77c40152952186..3123ee2f139c350c777f685e0bce02a62a93320c 100644 (file)
@@ -20,7 +20,6 @@
 #include <xen/delay.h>
 #include <xen/interrupt.h>
 #include <xen/time.h>
-#include <xen/timex.h>
 #include <xen/sched.h>
 
 #include <asm/mc146818rtc.h>
@@ -103,7 +102,7 @@ int __init check_nmi_watchdog (void)
         cpu = cpu_logical_map(j);
         prev_nmi_count[cpu] = irq_stat[cpu].__nmi_count;
     }
-    sti();
+    __sti();
     mdelay((10*1000)/nmi_hz); /* wait 10 ticks */
 
     for ( j = 0; j < smp_num_cpus; j++ )